
function flushCode() {
    $("#codeimg").attr("src","/code?date="+ new Date());
}
function login() {
    let username = $("#username").val();
    let password = $("#password").val();
    let iptcode = $("#codeipt").val();
    console.log(iptcode);
    $.ajax({
        url:"/login",
        type:"post",
        data:{
            "username":username,
            "password":password,
            "codeipt":iptcode
        },
        dataType:'json',
        success:function (data) {
            console.log(data);
            if (data != 0){
                alert("登录成功");
                window.location.href = "/backmanager";
            }else{
                $("#tips").html("登录信息输入错误，请重新输入");
                flushCode();
            }
        },
        error:function (data) {
            console.log(data);
        }
    })
}